package com.qky.controller.postController;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.multipart.MultipartFile;

import com.qky.model.post.Post;
import com.qky.model.region.Province;
import com.qky.model.user.User;
import com.qky.service.baseService.BaseService;
import com.qky.service.postService.PostService;
import com.qky.service.regionService.RegionService;

@Controller
@SessionAttributes("loginId")  
	public class AddPostController<E> {
	
	@Resource
	BaseService<E> baseService;
	@Resource
	RegionService regionService;
	@RequestMapping(value = "/addPost",method=RequestMethod.GET)
	public String addPostGet(ModelMap map) {
		return "post/addPost";
	}
	
	@RequestMapping(value = "/addPost",method=RequestMethod.POST)
	public String addPost(
		Post post,@ModelAttribute("loginId")int loginId) {
		post.setUId(loginId);
		post.setNowTime(new Date());
		post.setAddressName("中海国际");
		baseService.add((E)post);
		return "post/addPost";
	}
}
